Skip to content

Conversation

@jadosh123
Copy link

@jadosh123 jadosh123 commented Nov 16, 2025

GH-40673: Adds a test case to prevent regression of a bug where the internal object reused by apply() would corrupt externally stored DataFrames created with .copy(). This test verifies that store[0] and store[1] correctly contain independent copies of their respective groups.

pandas-devGH-40673: Adds a test case to prevent regression of a bug where the internal
object reused by apply() would corrupt externally stored DataFrames created
with .copy(). This test verifies that store[0] and store[1] correctly contain
independent copies of their respective groups.
@aa-lunar

This comment was marked as spam.

@9h7xrywp7z-hue

This comment was marked as spam.

@9h7xrywp7z-hue

This comment was marked as spam.

@b0rderc0ntr0l

This comment was marked as spam.

@jadosh123
Copy link
Author

All CI checks passed, the pull request is ready for review but i don't see a button to request a reviewer.
@pandas-dev/maintainers

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR - looking good!

# The expected output in store dict
expected_out = {0: df[out_mask[0]], 1: df[out_mask[1]]}

tm.assert_frame_equal(store[0], expected_out[0].drop("B", axis=1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected here can just be df.iloc[[0, 2], 1] I think.

expected_out = {0: df[out_mask[0]], 1: df[out_mask[1]]}

tm.assert_frame_equal(store[0], expected_out[0].drop("B", axis=1))
tm.assert_frame_equal(store[1], expected_out[1].drop("B", axis=1))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here.

}
)

# Empty dict to hold the chunks
Copy link
Member

@rhshadrach rhshadrach Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment and the ones below don't add anything that isn't already in the code. Can you remove them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Copy not working as expected within DataFrameGroupBy.apply function

5 participants